package com.thread.create;

import sun.applet.Main;

import java.util.concurrent.*;

/**
 *使用Callable创建线程
 *
 * @author jiangbang
 * @date 2016/6/16
 */
public class CallableDemo05 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // 创建线程(1个)
        ExecutorService ser = Executors.newFixedThreadPool(1);
        Race race = new Race();
        //获取值
        Future<Integer> result = ser.submit(race);
        int num = result.get();
        System.out.println(num);
        //停止服务
        ser.shutdown();
    }

}

class Race implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        return 1000;
    }
}